<?php
/**
 * 文件树的处理
 *
 */
class tree extends control {
	/**
	 * 获取目录 
	 *
	 */
	public function get_action() {
		global $_G;
		$tmpDir  = getgpc('tmpdir', 'P');
		$pid     = getgpc('id', 'P');
		$project = getgpc('project', 'P');
		$dir     = getgpc('dir', 'P');
		$pre     = $_G['config']['project']['pre_local'];

		if(!$project) {
			//获取根节点
			$files    = array(array('type' => 1, 'name' => $dir, 'dir' => '/'));
			$treeData = getTreeData($files, 'root', $dir, $pre);
			$treeData = json_encode($treeData);
		} else {
			$folder   = $pre . $project . $tmpDir;
			$files    = getFiles($folder);
			$treeData = getTreeData($files, $pid, $project, $pre);
			$treeData = json_encode($treeData);
		}

		echo $treeData;
		exit();
	}
}